package vn.edu.saigontech.ncms.service.impl;

import java.util.Collection;

import org.hibernate.Criteria;
import org.hibernate.criterion.Restrictions;

import vn.edu.saigontech.ncms.model.info.AdditionalInfo;
import vn.edu.saigontech.ncms.service.AdditionalInfoService;

@SuppressWarnings("unchecked")
public class AdditionalInfoServiceImpl extends HibernateGenericService<AdditionalInfo, Long> implements AdditionalInfoService {
	
	public Collection<AdditionalInfo> findBySchoolGradeId(Long offeringId) {
		Criteria additionalInfoCriteria = this.createCriteria();
		Criteria schoolGradeCriteria = additionalInfoCriteria.createCriteria("schoolGrade");
		schoolGradeCriteria.add(Restrictions.eq("id", offeringId));
		return schoolGradeCriteria.list();
	}

	@Override
	public AdditionalInfo findBySchool(String school) {
		Criteria additionalInfoCriteria = this.createCriteria();
		additionalInfoCriteria.add(Restrictions.eq("school", school));
		return (AdditionalInfo) additionalInfoCriteria.uniqueResult();
	}
}